package com.franklin.java.configuration.sql.type.ui;

import com.franklin.java.api.ui.table.AbstractTableModel;
import com.franklin.java.entity.sql.TypeMapping;


/**
 * @author Franklin
 * @since 2021/08/28 11:32
 */
public class TypeMappingModel extends AbstractTableModel<TypeMapping> {
    @Override
    protected String[] headerNames() {
        return new String[]{"columnType", "javaType"};
    }

    @Override
    protected Object[] toArray(TypeMapping rowData) {
        return new Object[]{rowData.getColumnType(),rowData.getJavaType()};
    }

    @Override
    protected <E> void setVal(TypeMapping rowData, int columnIndex, E value) {
        if (columnIndex == 0){
            rowData.setColumnType(value.toString());
        }else {
            rowData.setJavaType(value.toString());
        }
    }
}
